﻿using System;
using System.Collections.Generic;

namespace FDEE.Model
{
    public class BPL2 : BPTMBase
    {

        public BPL2(string typeName, string pierNumber,
            int height, double width, double lwidth,int calculatedHeight, int L1, int L2,
            int span) :
            base(typeName, pierNumber, height, width,lwidth, calculatedHeight,  L1, L2, span)
        {
        }


        public override void SetRebarList()
        {
            RebarList = new RebarCollection();
            #region 全局钢筋数量
            int N1 = 24; // 取决于L1,L2差是否是800
            int N21 = 6;
            int N22 = 5*2;
            int N3 = 8;
            int N4 = 6*2;
            int N5 =4;
          
            int N101 = 4;
            int N102 = 10;
            int N111 = 6 ;
            int N112 = 3;

            int N12 = 8*2;
            int N13 = 4*2;
         
            #endregion

            #region 1号钢筋
            double LEN1 = Width - 2 * 50 ;         
            if (LEN1 > 12000)
            {
                throw new Exception("钢筋超过定尺");
            }
            RebarList.Add(new MARebarRecord(1, 0, "", eDB.DB32, (int)LEN1, N1, eShapeType.MA));

            #endregion

            #region 2#
            //int C = (int)Math.Round((Width - 100 ), MidpointRounding.AwayFromZero);
            RebarList.Add(new MURebarRecord(2, 1, "", eDB.DB32, N21, eShapeType.MU, 500, 900 - 100 - 16 - 32, (int)LEN1, 200 - 50 - 32 - 16, 32*3));
            RebarList.Add(new MURebarRecord(2, 2, "", eDB.DB32, N22, eShapeType.MUC, 500, 290 - 32*2 - 60, (int)LEN1, 200 - 50 - 32 - 16, 0));
          
            #endregion

            #region 3#

            RebarList.Add(new MARebarRecord(3, 0, "", eDB.DB25, (int)LEN1, N3, eShapeType.MA));
            #endregion

            #region 4#

            RebarList.Add(new MARebarRecord(4, 0, "", eDB.DB16, (int)LEN1, N4, eShapeType.MA));

            #endregion
            #region 5#

            RebarList.Add(new MARebarRecord(5, 0, "", eDB.DB16, (int)LEN1, N5, eShapeType.MA));
            #endregion

            #region 6#

            int  quan = (int)Math.Round((Width  - 100) / 250, MidpointRounding.AwayFromZero);
            var  AA = Height - 2 * 50 - 2 * 16;
            var BB = L2 - 2 * 50 - 2 * 16;
            RebarList.Add(new MORebarRecord(6, 1, "", eDB.DB16, quan, eShapeType.MO, AA, BB));
            RebarList.Add(new MORebarRecord(6, 2, "", eDB.DB16, quan, eShapeType.MO, AA, 130 * 3 + 32));
            RebarList.Add(new MORebarRecord(6, 3, "", eDB.DB16, quan, eShapeType.MO, AA, 130  + 32));
            #endregion

            #region 7# 8# 9# 
            AA = CalculatedHeight - 2 * 50 - 16 - 25;
            BB = L1 - 2 * 50 - 2 * 16;
            quan = (int)Math.Round(Width / 150, MidpointRounding.AwayFromZero) + 1;
            RebarList.Add(new MCRebarRecord(7, 0, "", eDB.DB25, AA, BB, AA, quan, eShapeType.MCB));
            AA = CalculatedHeight - 2 * 50 - 25 - 25;
            RebarList.Add(new MCRebarRecord(8, 0, "", eDB.DB16, AA, BB, AA, quan, eShapeType.MCB));
            //quan = (int)Math.Round(Width / 300, MidpointRounding.AwayFromZero) + 1;
            quan = (int)(Math.Round(Width / 600, MidpointRounding.AwayFromZero) + 1) * 2;
            RebarList.Add(new MORebarRecord(9, 0, "", eDB.DB16, quan, eShapeType.MO, L1 - 2 * 50 - 2 * 16, 350));

            #endregion


            #region 10#,11#
            AA = 1500 - 50;
            BB = 2 * 217 + 120 + 2 * 25 + 2 * 12;
            BB = 294;
            RebarList.Add(new MCRebarRecord(10, 1, "", eDB.DB25, AA, BB, AA, N101, eShapeType.MCB));
            RebarList.Add(new MCRebarRecord(10, 2, "", eDB.DB12, AA, BB, AA, N102, eShapeType.MCB));

            RebarList.Add(new MURebarRecord(11, 1, "", eDB.DB12, N111, eShapeType.MUR, 1450, Height - 100, 1450, 109, 75));
            RebarList.Add(new MURebarRecord(11, 2, "", eDB.DB12, N112, eShapeType.MUR, 1450, Height - 100, 1450, 109, 75));
            #endregion

            #region 12#，13#

            int BlockThick = 200;

            AA = BlockThick - 2 * 50 - 2 * 12;
            BB = (int)Math.Round((L1 - L2) * 0.5 - 2 * 50 - 2 * 12, MidpointRounding.AwayFromZero);
            RebarList.Add(new MORebarRecord(12, 0, "", eDB.DB12, N12, eShapeType.MO, AA, BB));
            AA = Height - 2 * 50;
            BB = BlockThick - 2 * 50 - 2 * 12;
            RebarList.Add(new MCRebarRecord(13, 0, "", eDB.DB12, AA, BB, AA, N13, eShapeType.MCB));
    
        
            #endregion

        }

        public override void SetTendonList(ref System.Data.DataTable ElongTable)
        {
            TendonDistribute = new RebarTendonDistribute(320, new List<double>() { });
        }
    }
}
